package com.cskaoyan.day24.Homework24;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class Client02 {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1",5678);
        OutputStream out = socket.getOutputStream();
//        Scanner scanner = new Scanner(System.in);
//        String msg = scanner.nextLine();
//        out.write(msg.getBytes());
        FileInputStream in = new FileInputStream("zclient/a.txt");
        byte[] buf = new byte[1024];
        int readCount;
        out.write("1232141241424".getBytes());
        while ((readCount = in.read(buf))!=-1){
            out.write(buf,0,readCount);
        }
        out.write("end".getBytes());
        System.out.println("发送完毕");
        InputStream in1 = socket.getInputStream();
        int readCount2;
        readCount2 = in1.read(buf);
        System.out.println(new String(buf, 0, readCount2));
        socket.close();
    }
}
